/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mzm.ui.admin;

import com.mzm.api.MediaInfoDto;
import com.mzm.api.MediaType;
import com.mzm.api.PeriodicityType;

/**
 *
 * @author User
 */
public class MediaInfoEditorPanel extends javax.swing.JPanel {

    /**
     * Creates new form MediaInfoEditorPanel
     */
    public MediaInfoEditorPanel() {
        initComponents();
        ((EnumComboBox) mediaTypeCombo).setData(MediaType.class);
        ((EnumComboBox) PeriodicityCombo).setData(PeriodicityType.class);
    }
    
    public MediaInfoDto getMediaInfoDto() {
    	MediaInfoDto mediaInfo = new MediaInfoDto();
    	EnumComboBox mtCombo = (EnumComboBox) mediaTypeCombo;
    	EnumComboBox pCombo = (EnumComboBox) PeriodicityCombo;
    	mediaInfo.setMediaType((MediaType) mtCombo.getSelectedValue());
    	mediaInfo.setPeriodicityType((PeriodicityType) pCombo.getSelectedValue());
    	mediaInfo.setName(mediaNameTF.getText());
		return mediaInfo;
	}
    
	public void clear(){
		mediaNameTF.setText("");
	}

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mediaTypeCombo = new EnumComboBox();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        PeriodicityCombo = new EnumComboBox();
        jLabel3 = new javax.swing.JLabel();
        mediaNameTF = new javax.swing.JTextField();

        jLabel1.setText("Media Type:");

        jLabel2.setText("Periodicity:");

        jLabel3.setText("Name:");

        mediaNameTF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mediaNameTFActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(32, 32, 32)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 94, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(mediaTypeCombo, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(PeriodicityCombo, 0, 131, Short.MAX_VALUE)
                    .addComponent(mediaNameTF))
                .addGap(57, 57, 57))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(46, 46, 46)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(mediaTypeCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(PeriodicityCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(mediaNameTF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(158, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void mediaNameTFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mediaNameTFActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_mediaNameTFActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox PeriodicityCombo;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JTextField mediaNameTF;
    private javax.swing.JComboBox mediaTypeCombo;
    // End of variables declaration//GEN-END:variables
}
